package heven.holt.wan.android.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import heven.holt.wan.android.databinding.ItemNavigationSystemBinding
import heven.holt.wan.android.model.ProjectModel

class NavigationSystemAdapter(
    private val data: List<ProjectModel>
) :
    RecyclerView.Adapter<NavigationSystemAdapter.NavigationSystemViewHolder>() {
    class NavigationSystemViewHolder(
        val binding: ItemNavigationSystemBinding
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NavigationSystemViewHolder =
        NavigationSystemViewHolder(
            ItemNavigationSystemBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
        )

    override fun onBindViewHolder(holder: NavigationSystemViewHolder, position: Int) {
        holder.binding.projectModel = data[position]
        holder.binding.executePendingBindings()
    }

    override fun getItemCount(): Int = data.size
}